package siga.visao_academico;

import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import siga.banco.conexao;
import siga.visao_busca.buscaVer;
import siga.visao.index;
import siga.visao.verErros;

/**
 *
 * @author rafaelfrasson
 */
public class GestaoCadCurso extends javax.swing.JInternalFrame {
    List LRCurso = new ArrayList();
    List LRCTitular = new ArrayList();
    List LRCAdj = new ArrayList();
    Object[] JOopcoes = {"Sim","Não"};
    /** Creates new form GestaoCadCurso */
    public GestaoCadCurso() {
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jpPCursos = new javax.swing.JPanel();
        barraFerramentaFonecedor = new javax.swing.JToolBar();
        btNovo = new javax.swing.JButton();
        btAlterar = new javax.swing.JButton();
        btCancelar = new javax.swing.JButton();
        btSalvar = new javax.swing.JButton();
        btRemover = new javax.swing.JButton();
        btSair = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jtfCodigo = new javax.swing.JTextField();
        jtfDescricao = new javax.swing.JTextField();
        jtfSigla = new javax.swing.JTextField();
        jtfCoordTitula = new javax.swing.JTextField();
        jtfCoordAdj = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtfObs = new javax.swing.JTextPane();
        jbBuscar = new javax.swing.JButton();
        jbBuscar1 = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jtfCurso = new javax.swing.JComboBox();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtCurso = new javax.swing.JTable();
        jtfCodTitular = new javax.swing.JTextField();
        jtfCodAdj = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jtfDt_inicio = new javax.swing.JFormattedTextField();
        jLabel9 = new javax.swing.JLabel();
        jtfDt_fim = new javax.swing.JFormattedTextField();
        jLabel10 = new javax.swing.JLabel();
        jtfFund_lei = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jtfFund_desc = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jtfAuto_parec = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jtfAuto_dec = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jtfDOESC_nr = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jtfDOESC_dt = new javax.swing.JFormattedTextField();
        jLabel16 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jtfPerfil = new javax.swing.JEditorPane();
        jLabel17 = new javax.swing.JLabel();
        jtfArea_prof = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        jtfTitulacao = new javax.swing.JTextField();
        jtfDt_Decreto_federal = new javax.swing.JFormattedTextField();
        jLabel19 = new javax.swing.JLabel();

        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        setTitle("Cadastro de Cursos");
        setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/cheque_16x16.png"))); // NOI18N
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameOpened(evt);
            }
        });

        jpPCursos.setAutoscrolls(true);
        jpPCursos.setName("jpPCursos"); // NOI18N

        barraFerramentaFonecedor.setFloatable(false);
        barraFerramentaFonecedor.setRollover(true);
        barraFerramentaFonecedor.setName("barraFerramentaFonecedor"); // NOI18N

        btNovo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/novo_32x32.png"))); // NOI18N
        btNovo.setMnemonic('N');
        btNovo.setText("Novo");
        btNovo.setToolTipText("Inseri um Novo Cadastro");
        btNovo.setFocusable(false);
        btNovo.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btNovo.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btNovo.setName("btNovo"); // NOI18N
        btNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btNovoActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btNovo);

        btAlterar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/editar_32x32.png"))); // NOI18N
        btAlterar.setMnemonic('A');
        btAlterar.setText("Alterar");
        btAlterar.setToolTipText("Alterar um  Cadastro");
        btAlterar.setEnabled(false);
        btAlterar.setFocusable(false);
        btAlterar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btAlterar.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btAlterar.setName("btAlterar"); // NOI18N
        btAlterar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAlterarActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btAlterar);

        btCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/cancelar_32x32.png"))); // NOI18N
        btCancelar.setMnemonic('C');
        btCancelar.setText("Cancelar");
        btCancelar.setToolTipText("Cancelar um Cadastro");
        btCancelar.setEnabled(false);
        btCancelar.setFocusable(false);
        btCancelar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btCancelar.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btCancelar.setName("btCancelar"); // NOI18N
        btCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCancelarActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btCancelar);

        btSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/salvar_32x32.png"))); // NOI18N
        btSalvar.setMnemonic('S');
        btSalvar.setText("Salvar");
        btSalvar.setToolTipText("Salvar um Cadastro");
        btSalvar.setEnabled(false);
        btSalvar.setFocusable(false);
        btSalvar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btSalvar.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btSalvar.setName("btSalvar"); // NOI18N
        btSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSalvarActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btSalvar);

        btRemover.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/remover_32x32.png"))); // NOI18N
        btRemover.setMnemonic('R');
        btRemover.setText("Remover");
        btRemover.setToolTipText("Remove um Cadastro");
        btRemover.setEnabled(false);
        btRemover.setFocusable(false);
        btRemover.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btRemover.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btRemover.setName("btRemover"); // NOI18N
        btRemover.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btRemoverActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btRemover);

        btSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/sair_32x32.png"))); // NOI18N
        btSair.setMnemonic('S');
        btSair.setText("Sair");
        btSair.setToolTipText("Sair da Janela");
        btSair.setFocusable(false);
        btSair.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btSair.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btSair.setName("btSair"); // NOI18N
        btSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSairActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btSair);

        jLabel1.setText("Código");
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText("Nome do Curso");
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel3.setText("Sigla");
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel4.setText("Coordenador Titular");
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel5.setText("Coordenador Adjunto");
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel6.setText("Reconhecimento");
        jLabel6.setName("jLabel6"); // NOI18N

        jtfCodigo.setEditable(false);
        jtfCodigo.setName("jtfCodigo"); // NOI18N

        jtfDescricao.setEditable(false);
        jtfDescricao.setName("jtfDescricao"); // NOI18N

        jtfSigla.setEditable(false);
        jtfSigla.setName("jtfSigla"); // NOI18N

        jtfCoordTitula.setEditable(false);
        jtfCoordTitula.setName("jtfCoordTitula"); // NOI18N

        jtfCoordAdj.setEditable(false);
        jtfCoordAdj.setName("jtfCoordAdj"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jtfObs.setEnabled(false);
        jtfObs.setName("jtfObs"); // NOI18N
        jScrollPane1.setViewportView(jtfObs);

        jbBuscar.setFont(new java.awt.Font("Dialog", 0, 10));
        jbBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/busca_16x16.png"))); // NOI18N
        jbBuscar.setText("Buscar");
        jbBuscar.setEnabled(false);
        jbBuscar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbBuscar.setMargin(new java.awt.Insets(2, 2, 2, 2));
        jbBuscar.setName("jbBuscar"); // NOI18N
        jbBuscar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbBuscarActionPerformed(evt);
            }
        });

        jbBuscar1.setFont(new java.awt.Font("Dialog", 0, 10));
        jbBuscar1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/busca_16x16.png"))); // NOI18N
        jbBuscar1.setText("Buscar");
        jbBuscar1.setEnabled(false);
        jbBuscar1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbBuscar1.setMargin(new java.awt.Insets(2, 2, 2, 2));
        jbBuscar1.setName("jbBuscar1"); // NOI18N
        jbBuscar1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbBuscar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbBuscar1ActionPerformed(evt);
            }
        });

        jLabel7.setText("Clonar disciplinas");
        jLabel7.setName("jLabel7"); // NOI18N

        jtfCurso.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jtfCurso.setEnabled(false);
        jtfCurso.setName("jtfCurso"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jtCurso.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Cógigo", "Nome do Curso", "Sigla", "Coordenador Titular", "Coordenador Adjunto", "Reconhecimento"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jtCurso.setName("jtCurso"); // NOI18N
        jtCurso.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jtCursoMouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(jtCurso);
        jtCurso.getColumnModel().getColumn(0).setPreferredWidth(100);
        jtCurso.getColumnModel().getColumn(0).setMaxWidth(100);
        jtCurso.getColumnModel().getColumn(2).setPreferredWidth(50);
        jtCurso.getColumnModel().getColumn(2).setMaxWidth(50);

        jtfCodTitular.setEditable(false);
        jtfCodTitular.setName("jtfCodTitular"); // NOI18N

        jtfCodAdj.setEditable(false);
        jtfCodAdj.setName("jtfCodAdj"); // NOI18N

        jLabel8.setText("Data de Início");
        jLabel8.setName("jLabel8"); // NOI18N

        jtfDt_inicio.setEditable(false);
        try {
            jtfDt_inicio.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jtfDt_inicio.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jtfDt_inicio.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jtfDt_inicio.setName("jtfDt_inicio"); // NOI18N

        jLabel9.setText("Data de Con.");
        jLabel9.setName("jLabel9"); // NOI18N

        jtfDt_fim.setEditable(false);
        try {
            jtfDt_fim.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jtfDt_fim.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jtfDt_fim.setName("jtfDt_fim"); // NOI18N

        jLabel10.setText("Fund. Lei");
        jLabel10.setToolTipText("Fundamentação Legal");
        jLabel10.setName("jLabel10"); // NOI18N

        jtfFund_lei.setEditable(false);
        jtfFund_lei.setToolTipText("Fundamentação Legal");
        jtfFund_lei.setName("jtfFund_lei"); // NOI18N

        jLabel11.setText("Decreto Fed.");
        jLabel11.setToolTipText("Decreto Federal");
        jLabel11.setName("jLabel11"); // NOI18N

        jtfFund_desc.setEditable(false);
        jtfFund_desc.setToolTipText("Decreto Federal");
        jtfFund_desc.setName("jtfFund_desc"); // NOI18N

        jLabel12.setText("Parec. de Auto.");
        jLabel12.setToolTipText("Parecer de Autorização");
        jLabel12.setName("jLabel12"); // NOI18N

        jtfAuto_parec.setEditable(false);
        jtfAuto_parec.setToolTipText("Parecer de Autorização");
        jtfAuto_parec.setName("jtfAuto_parec"); // NOI18N

        jLabel13.setText("Decreto Auto.");
        jLabel13.setName("jLabel13"); // NOI18N

        jtfAuto_dec.setEditable(false);
        jtfAuto_dec.setName("jtfAuto_dec"); // NOI18N

        jLabel14.setText("DOESC Nro.");
        jLabel14.setName("jLabel14"); // NOI18N

        jtfDOESC_nr.setEditable(false);
        jtfDOESC_nr.setName("jtfDOESC_nr"); // NOI18N

        jLabel15.setText("DOESC Data");
        jLabel15.setName("jLabel15"); // NOI18N

        jtfDOESC_dt.setEditable(false);
        try {
            jtfDOESC_dt.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jtfDOESC_dt.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jtfDOESC_dt.setName("jtfDOESC_dt"); // NOI18N

        jLabel16.setText("Perfil Profissional de Conclusão");
        jLabel16.setName("jLabel16"); // NOI18N

        jScrollPane3.setName("jScrollPane3"); // NOI18N

        jtfPerfil.setEnabled(false);
        jtfPerfil.setName("jtfPerfil"); // NOI18N
        jScrollPane3.setViewportView(jtfPerfil);

        jLabel17.setText("Área Profissional");
        jLabel17.setName("jLabel17"); // NOI18N

        jtfArea_prof.setEditable(false);
        jtfArea_prof.setName("jtfArea_prof"); // NOI18N

        jLabel18.setText("Titulação");
        jLabel18.setName("jLabel18"); // NOI18N

        jtfTitulacao.setEditable(false);
        jtfTitulacao.setName("jtfTitulacao"); // NOI18N

        try {
            jtfDt_Decreto_federal.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jtfDt_Decreto_federal.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jtfDt_Decreto_federal.setEnabled(false);
        jtfDt_Decreto_federal.setName("jtfDt_Decreto_federal"); // NOI18N

        jLabel19.setText("Data Decreto");
        jLabel19.setName("jLabel19"); // NOI18N

        javax.swing.GroupLayout jpPCursosLayout = new javax.swing.GroupLayout(jpPCursos);
        jpPCursos.setLayout(jpPCursosLayout);
        jpPCursosLayout.setHorizontalGroup(
            jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(barraFerramentaFonecedor, javax.swing.GroupLayout.DEFAULT_SIZE, 1141, Short.MAX_VALUE)
            .addGroup(jpPCursosLayout.createSequentialGroup()
                .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jpPCursosLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jpPCursosLayout.createSequentialGroup()
                                .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jpPCursosLayout.createSequentialGroup()
                                        .addComponent(jtfCodAdj, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jtfCoordAdj, javax.swing.GroupLayout.PREFERRED_SIZE, 946, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jpPCursosLayout.createSequentialGroup()
                                        .addComponent(jtfCodTitular, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jtfCoordTitula))
                                    .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jpPCursosLayout.createSequentialGroup()
                                        .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel1)
                                            .addComponent(jtfCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel2)
                                            .addComponent(jtfDescricao, javax.swing.GroupLayout.DEFAULT_SIZE, 851, Short.MAX_VALUE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jtfSigla, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel3))))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jbBuscar)
                                    .addComponent(jbBuscar1)))
                            .addGroup(jpPCursosLayout.createSequentialGroup()
                                .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(jpPCursosLayout.createSequentialGroup()
                                        .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel8)
                                            .addComponent(jtfDt_inicio, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jtfDt_fim)
                                            .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel10)
                                            .addComponent(jtfFund_lei, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jtfFund_desc)
                                            .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                                    .addComponent(jLabel17)
                                    .addComponent(jLabel18)
                                    .addComponent(jtfArea_prof, javax.swing.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE)
                                    .addComponent(jtfTitulacao))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jpPCursosLayout.createSequentialGroup()
                                        .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jtfDt_Decreto_federal)
                                            .addComponent(jLabel19, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel12)
                                            .addComponent(jtfAuto_parec, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel13)
                                            .addComponent(jtfAuto_dec, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel14)
                                            .addComponent(jtfDOESC_nr, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel15)
                                            .addComponent(jtfDOESC_dt, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jtfCurso, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                                    .addGroup(jpPCursosLayout.createSequentialGroup()
                                        .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel6))
                                        .addGap(12, 12, 12)
                                        .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel16)
                                            .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 471, javax.swing.GroupLayout.PREFERRED_SIZE))))))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jpPCursosLayout.setVerticalGroup(
            jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpPCursosLayout.createSequentialGroup()
                .addComponent(barraFerramentaFonecedor, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jpPCursosLayout.createSequentialGroup()
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtfDOESC_dt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpPCursosLayout.createSequentialGroup()
                        .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jpPCursosLayout.createSequentialGroup()
                                .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jpPCursosLayout.createSequentialGroup()
                                        .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addGroup(jpPCursosLayout.createSequentialGroup()
                                                .addComponent(jLabel1)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jtfCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jpPCursosLayout.createSequentialGroup()
                                                .addComponent(jLabel2)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jtfDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel4))
                                    .addGroup(jpPCursosLayout.createSequentialGroup()
                                        .addComponent(jLabel3)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jtfSigla, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jtfCodTitular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jtfCoordTitula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jtfCoordAdj, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jtfCodAdj, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jpPCursosLayout.createSequentialGroup()
                                .addComponent(jbBuscar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jbBuscar1)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(jpPCursosLayout.createSequentialGroup()
                                        .addComponent(jLabel8)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jtfDt_inicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jpPCursosLayout.createSequentialGroup()
                                        .addComponent(jLabel9)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jtfDt_fim, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(jpPCursosLayout.createSequentialGroup()
                                        .addComponent(jLabel10)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jtfFund_lei, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jpPCursosLayout.createSequentialGroup()
                                        .addComponent(jLabel11)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jtfFund_desc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGroup(jpPCursosLayout.createSequentialGroup()
                                    .addComponent(jLabel19)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jtfDt_Decreto_federal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpPCursosLayout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtfAuto_parec, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpPCursosLayout.createSequentialGroup()
                                .addComponent(jLabel13)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtfAuto_dec, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpPCursosLayout.createSequentialGroup()
                                .addComponent(jLabel14)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtfDOESC_nr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpPCursosLayout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtfCurso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jpPCursosLayout.createSequentialGroup()
                        .addComponent(jLabel17)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtfArea_prof, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel18)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtfTitulacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jpPCursosLayout.createSequentialGroup()
                        .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(jLabel16))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpPCursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE))))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jpPCursos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpPCursos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btNovoActionPerformed
        btSalvar.setEnabled(!btSalvar.isEnabled());
        btCancelar.setEnabled(!btCancelar.isEnabled());
        btNovo.setEnabled(!btNovo.isEnabled());
        btAlterar.setEnabled(false);
        btRemover.setEnabled(false);
        gerenciaCampos();
        LimpaCampos();
}//GEN-LAST:event_btNovoActionPerformed

    private void btAlterarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAlterarActionPerformed
        gerenciaBotao();
        gerenciaCampos();
}//GEN-LAST:event_btAlterarActionPerformed

    private void btCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancelarActionPerformed
        if(btCancelar.isEnabled()){
            if(!btNovo.isEnabled()){
                btSalvar.setEnabled(!btSalvar.isEnabled());
                btCancelar.setEnabled(!btCancelar.isEnabled());
                btNovo.setEnabled(!btNovo.isEnabled());
            }else{
                gerenciaBotao();
            }
            gerenciaCampos();
            LimpaCampos();
        }
}//GEN-LAST:event_btCancelarActionPerformed

    private void btSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSalvarActionPerformed
        try {
            if(!jtfCodigo.getText().equals("")){
                    if(!jtfDescricao.getText().equals("")){
                        if(!jtfSigla.getText().equals("")){
                            if(!jtfCodTitular.getText().equals("")){
                                String codAdj, dcodAdj,obs,dobs;
                                if(jtfCodAdj.getText().equals("")){codAdj="";dcodAdj="";}else{codAdj=",cod_coord_adj";dcodAdj=","+jtfCodAdj.getText();}
                                if(jtfObs.getText().equals("")){obs="";dobs="";}else{obs=",desc_reconhecimento";dobs=",\""+jtfObs.getText()+"\"";}
                                if(!jtfDt_inicio.getText().equals("  /  /    ")){obs+=",dt_ini";dobs+=",\""+new SimpleDateFormat("yyyy-MM-dd").format(new SimpleDateFormat("dd/MM/yyyy").parse(jtfDt_inicio.getText()))+"\"";}
                                if(!jtfDt_fim.getText().equals("  /  /    ")){obs+=",dt_fim";dobs+=",\""+new SimpleDateFormat("yyyy-MM-dd").format(new SimpleDateFormat("dd/MM/yyyy").parse(jtfDt_fim.getText()))+"\"";}
                                if(!jtfFund_lei.getText().equals("")){obs+=",fund_lei";dobs+=",\""+jtfFund_lei.getText()+"\"";}
                                if(!jtfFund_desc.getText().equals("")){obs+=",fund_dec";dobs+=",\""+jtfFund_desc.getText()+"\"";}
                                if(!jtfAuto_parec.getText().equals("")){obs+=",auto_parecer";dobs+=",\""+jtfAuto_parec.getText()+"\"";}
                                if(!jtfAuto_dec.getText().equals("")){obs+=",auto_dec";dobs+=",\""+jtfAuto_dec.getText()+"\"";}
                                if(!jtfDOESC_nr.getText().equals("")){obs+=",diario_oficial_nr";dobs+=",\""+jtfDOESC_nr.getText()+"\"";}
                                if(!jtfDOESC_dt.getText().equals("  /  /    ")){obs+=",diario_oficial_dt";dobs+=",\""+new SimpleDateFormat("yyyy-MM-dd").format(new SimpleDateFormat("dd/MM/yyyy").parse(jtfDOESC_dt.getText()))+"\"";}
                                if(!jtfPerfil.getText().equals("")){obs+=",perfil";dobs+=",\""+jtfPerfil.getText()+"\"";}
                                if(!jtfArea_prof.getText().equals("")){obs+=",area_prof";dobs+=",\""+jtfArea_prof.getText()+"\"";}
                                if(!jtfTitulacao.getText().equals("")){obs+=",titulacao";dobs+=",\""+jtfTitulacao.getText()+"\"";}
                                conexao.stm.executeUpdate("replace into grade_curso(codigo, cod_emp, descricao,sigla,cod_coord_ti"+codAdj+""+obs+") " +
                                        "values("+jtfCodigo.getText()+","+index.cod_emp+",\""+jtfDescricao.getText()+"\",\""+jtfSigla.getText()+"\","+jtfCodTitular.getText()+dcodAdj+dobs+")");
                                gerenciaBotao();
                                gerenciaCampos();
                                LimpaCampos();
                                CarregaTabela();
                            }else{
                                JOptionPane.showMessageDialog(null, "Campo Coordenador Titular é obrigatório.","Alerta do Sistema.",JOptionPane.INFORMATION_MESSAGE);
                                jtfCodTitular.requestFocus();
                            }
                    }else{
                        JOptionPane.showMessageDialog(null, "Campo Sigla é obrigatório.","Alerta do Sistema.",JOptionPane.INFORMATION_MESSAGE);
                        jtfSigla.requestFocus();
                    }
                }else{
                    JOptionPane.showMessageDialog(null, "Campo Nome do Curso é obrigatório.","Alerta do Sistema.",JOptionPane.INFORMATION_MESSAGE);
                    jtfDescricao.requestFocus();
                }
            }else{
                JOptionPane.showMessageDialog(null, "Campo Código é obrigatório.","Alerta do Sistema.",JOptionPane.INFORMATION_MESSAGE);
                jtfCodigo.requestFocus();
            }
        } catch (ParseException ex) {
            verErros.setErro(ex.getMessage());
        } catch (SQLException ex) {
            verErros.setErro(ex.getMessage());
        }
}//GEN-LAST:event_btSalvarActionPerformed

    private void btRemoverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btRemoverActionPerformed
        if (JOptionPane.showOptionDialog(null, "Deseja remover esse Curso?\nEsta ação implica em remover todos os registros de Turmas, Diários e Financeiros.", "Removendo Curso", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, JOopcoes, JOopcoes[0]) == JOptionPane.YES_OPTION) {
            try {
                conexao.stm.executeUpdate("delete from grade_curso where codigo="+jtfCodigo.getText()+" and cod_emp="+index.cod_emp+"");
                LimpaCampos();
                CarregaTabela();
            } catch (SQLException ex) {
                verErros.setErro(ex.getMessage());
            }
        }
}//GEN-LAST:event_btRemoverActionPerformed

    private void btSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSairActionPerformed
        try {
            btCancelarActionPerformed(evt);
            dispose();
        } catch (Throwable ex) {
            Logger.getLogger(GestaoCadCurso.class.getName()).log(Level.SEVERE, null, ex);
        }
}//GEN-LAST:event_btSairActionPerformed

    private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameOpened
        CarregaTabela();
        carregaCurso();
    }//GEN-LAST:event_formInternalFrameOpened

    private void jtCursoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jtCursoMouseClicked
        try {
            if (btNovo.isEnabled()) {
                btAlterar.setEnabled(true);
                btRemover.setEnabled(true);
            }
            javax.swing.table.DefaultTableModel jtb = (javax.swing.table.DefaultTableModel) jtCurso.getModel();
            jtfCodigo.setText("" + jtb.getValueAt(jtCurso.getSelectedRow(), 0));
            jtfDescricao.setText("" + jtb.getValueAt(jtCurso.getSelectedRow(), 1));
            jtfCoordTitula.setText("" + jtb.getValueAt(jtCurso.getSelectedRow(), 3));
            jtfCoordAdj.setText("" + jtb.getValueAt(jtCurso.getSelectedRow(), 4));
            jtfCodTitular.setText("" + LRCTitular.get(jtCurso.getSelectedRow()));
            jtfCodAdj.setText("" + LRCAdj.get(jtCurso.getSelectedRow()));
            jtfSigla.setText("" + jtb.getValueAt(jtCurso.getSelectedRow(), 2));
            jtfObs.setText("" + jtb.getValueAt(jtCurso.getSelectedRow(), 5));
            conexao.Query("select * from grade_curso where cod_emp=" + index.cod_emp + " and codigo=" + jtb.getValueAt(jtCurso.getSelectedRow(), 0));
            conexao.rs.next();
            jtfDt_inicio.setText((conexao.rs.getString("dt_ini")==null)? "" : new SimpleDateFormat("dd/MM/yyyy").format(conexao.rs.getDate("dt_ini")));
            jtfDt_fim.setText((conexao.rs.getString("dt_fim")==null)? "" : new SimpleDateFormat("dd/MM/yyyy").format(conexao.rs.getDate("dt_fim")));
            jtfFund_lei.setText((conexao.rs.getString("fund_lei")==null)? "" : conexao.rs.getString("fund_lei"));
            jtfFund_desc.setText((conexao.rs.getString("fund_dec")==null)? "" : conexao.rs.getString("fund_dec"));
            jtfAuto_parec.setText((conexao.rs.getString("auto_parecer")==null)? "" : conexao.rs.getString("auto_parecer"));
            jtfAuto_dec.setText((conexao.rs.getString("auto_dec")==null)? "" : conexao.rs.getString("auto_dec"));
            jtfAuto_dec.setText((conexao.rs.getString("auto_dec")==null)? "" : conexao.rs.getString("auto_dec"));
            jtfDOESC_nr.setText((conexao.rs.getString("diario_oficial_nr")==null)? "" : conexao.rs.getString("diario_oficial_nr"));
            jtfDOESC_dt.setText((conexao.rs.getString("diario_oficial_dt")==null)? "" : new SimpleDateFormat("dd/MM/yyyy").format(conexao.rs.getDate("diario_oficial_dt")));
            jtfPerfil.setText((conexao.rs.getString("perfil")==null)? "" : conexao.rs.getString("perfil"));
            jtfArea_prof.setText((conexao.rs.getString("area_prof")==null)? "" : conexao.rs.getString("area_prof"));
            jtfTitulacao.setText((conexao.rs.getString("titulacao")==null)? "" : conexao.rs.getString("titulacao"));
        } catch (SQLException ex) {
            verErros.setErro(ex.getMessage());
        }

    }//GEN-LAST:event_jtCursoMouseClicked

    private void jbBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbBuscarActionPerformed
        buscaVer.setTipo("Docente");
        buscaVer bv = new buscaVer(null,true);
        bv.setLocation((index.tela.width-bv.getWidth())/2, (index.tela.height-bv.getHeight())/2);
        bv.setVisible(true);
        if(buscaVer.isConfirmaBusca()){
            jtfCodTitular.setText(index.LRpessoa.get(0).toString());
            jtfCoordTitula.setText(index.LRpessoa.get(1).toString());
        }
        index.LRpessoa.add(0, "");
        index.LRpessoa.add(1, "");
    }//GEN-LAST:event_jbBuscarActionPerformed

    private void jbBuscar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbBuscar1ActionPerformed
        buscaVer.setTipo("Docente");
        buscaVer bv = new buscaVer(null,true);
        bv.setLocation((index.tela.width-bv.getWidth())/2, (index.tela.height-bv.getHeight())/2);
        bv.setVisible(true);
        if(buscaVer.isConfirmaBusca()){
            jtfCodAdj.setText(index.LRpessoa.get(0).toString());
            jtfCoordAdj.setText(index.LRpessoa.get(1).toString());
        }
        index.LRpessoa.add(0, "");
        index.LRpessoa.add(1, "");
    }//GEN-LAST:event_jbBuscar1ActionPerformed

    private void CarregaTabela(){
        try {
            javax.swing.table.DefaultTableModel jtb = (javax.swing.table.DefaultTableModel) jtCurso.getModel();
            for (int x = jtCurso.getRowCount() - 1; x >= 0; --x) {
                jtb.removeRow(x);
            }
            conexao.Query("SELECT gc.*, p.descricao as desc_titular, p2.descricao as desc_adjunto FROM grade_curso gc " +
                    "left join pessoas p on p.codigo=gc.cod_coord_ti and p.cod_emp=gc.cod_emp " +
                    "left join pessoas p2 on p2.codigo=gc.cod_coord_adj and p2.cod_emp=gc.cod_emp " +
                    "where gc.cod_emp=" + index.cod_emp + " order by gc.descricao");
            LRCTitular.removeAll(LRCAdj);
            LRCAdj.removeAll(LRCAdj);
            while (conexao.rs.next()) {
                LRCTitular.add((conexao.rs.getString("cod_coord_ti")==null) ? "" : conexao.rs.getString("cod_coord_ti"));
                LRCAdj.add((conexao.rs.getString("cod_coord_adj")==null) ? "" : conexao.rs.getString("cod_coord_adj"));
                jtb.addRow(new Object[]{conexao.rs.getString("codigo"), conexao.rs.getString("descricao"), conexao.rs.getString("sigla"), conexao.rs.getString("desc_titular"),(conexao.rs.getString("desc_adjunto")==null)?"":conexao.rs.getString("desc_adjunto"), (conexao.rs.getString("desc_reconhecimento")==null)?"":conexao.rs.getString("desc_reconhecimento")});
            }
        } catch (SQLException ex) {
            verErros.setErro(ex.getMessage());
        }
    }

    private void carregaCurso(){
        jtfCurso.removeAllItems();
        try {
            conexao.Query("select gc.codigo,gc.descricao from grade_curso gc" +
                    " where gc.cod_emp="+index.cod_emp+" order by gc.descricao");
            LRCurso.add(0);
            jtfCurso.addItem("Selecione um Curso para clonagem.");
            while(conexao.rs.next()){
                LRCurso.add(conexao.rs.getString("codigo"));
                jtfCurso.addItem(conexao.rs.getString("descricao"));
            }
        } catch (SQLException ex) {
            verErros.setErro(ex.getMessage());
        }
    }

    private void gerenciaCampos(){
        jtfCodigo.setEditable(!jtfCodigo.isEditable());
        jtfDescricao.setEditable(!jtfDescricao.isEditable());
        jtfCodTitular.setEditable(!jtfCodTitular.isEditable());
        jtfCodAdj.setEditable(!jtfCodAdj.isEditable());
        jtfSigla.setEditable(!jtfSigla.isEditable());
        jtfObs.setEnabled(!jtfObs.isEnabled());
        jtfCurso.setEnabled(!jtfCurso.isEnabled());
        jbBuscar.setEnabled(!jbBuscar.isEnabled());
        jbBuscar1.setEnabled(!jbBuscar1.isEnabled());
        jtfDt_inicio.setEditable(!jtfDOESC_dt.isEditable());
        jtfDt_fim.setEditable(!jtfDOESC_dt.isEditable());
        jtfFund_lei.setEditable(!jtfDOESC_dt.isEditable());
        jtfFund_desc.setEditable(!jtfDOESC_dt.isEditable());
        jtfAuto_parec.setEditable(!jtfDOESC_dt.isEditable());
        jtfAuto_dec.setEditable(!jtfDOESC_dt.isEditable());
        jtfAuto_dec.setEditable(!jtfDOESC_dt.isEditable());
        jtfDOESC_nr.setEditable(!jtfDOESC_dt.isEditable());
        jtfArea_prof.setEditable(!jtfDOESC_dt.isEditable());
        jtfTitulacao.setEditable(!jtfDOESC_dt.isEditable());
        jtfDOESC_dt.setEditable(!jtfDOESC_dt.isEditable());
        jtfPerfil.setEnabled(!jtfPerfil.isEnabled());
    }

    private void gerenciaBotao(){
        btNovo.setEnabled(!btNovo.isEnabled());
        btAlterar.setEnabled(!btAlterar.isEnabled());
        btCancelar.setEnabled(!btCancelar.isEnabled());
        btRemover.setEnabled(!btRemover.isEnabled());
        btSalvar.setEnabled(!btSalvar.isEnabled());
    }

    private void LimpaCampos(){
        jtfCodigo.setText("");
        jtfDescricao.setText("");
        jtfCoordTitula.setText("");
        jtfCoordAdj.setText("");
        jtfCodTitular.setText("");
        jtfCodAdj.setText("");
        jtfSigla.setText("");
        jtfObs.setText("");
        jtfCurso.setSelectedIndex(0);
        jtfDt_inicio.setText("  /  /    ");
        jtfDt_fim.setText("  /  /    ");
        jtfFund_lei.setText("");
        jtfFund_desc.setText("");
        jtfAuto_parec.setText("");
        jtfAuto_dec.setText("");
        jtfAuto_dec.setText("");
        jtfDOESC_nr.setText("");
        jtfDOESC_dt.setText("  /  /    ");
        jtfPerfil.setText("");
        jtfTitulacao.setText("");
        jtfArea_prof.setText("");
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JToolBar barraFerramentaFonecedor;
    private javax.swing.JButton btAlterar;
    private javax.swing.JButton btCancelar;
    private javax.swing.JButton btNovo;
    private javax.swing.JButton btRemover;
    private javax.swing.JButton btSair;
    private javax.swing.JButton btSalvar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JButton jbBuscar;
    private javax.swing.JButton jbBuscar1;
    private javax.swing.JPanel jpPCursos;
    private javax.swing.JTable jtCurso;
    private javax.swing.JTextField jtfArea_prof;
    private javax.swing.JTextField jtfAuto_dec;
    private javax.swing.JTextField jtfAuto_parec;
    private javax.swing.JTextField jtfCodAdj;
    private javax.swing.JTextField jtfCodTitular;
    private javax.swing.JTextField jtfCodigo;
    private javax.swing.JTextField jtfCoordAdj;
    private javax.swing.JTextField jtfCoordTitula;
    private javax.swing.JComboBox jtfCurso;
    private javax.swing.JFormattedTextField jtfDOESC_dt;
    private javax.swing.JTextField jtfDOESC_nr;
    private javax.swing.JTextField jtfDescricao;
    private javax.swing.JFormattedTextField jtfDt_Decreto_federal;
    private javax.swing.JFormattedTextField jtfDt_fim;
    private javax.swing.JFormattedTextField jtfDt_inicio;
    private javax.swing.JTextField jtfFund_desc;
    private javax.swing.JTextField jtfFund_lei;
    private javax.swing.JTextPane jtfObs;
    private javax.swing.JEditorPane jtfPerfil;
    private javax.swing.JTextField jtfSigla;
    private javax.swing.JTextField jtfTitulacao;
    // End of variables declaration//GEN-END:variables

}
